﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class PaymentMap : EntityConfigurationBase<Payment>
    {
        public PaymentMap()
        {
            this.Property(p => p.Payee).HasMaxLength(20).IsRequired();
            this.Property(p => p.CollectionBank).HasMaxLength(30).IsRequired();
            this.Property(p => p.BankNumber).HasMaxLength(20).IsRequired();
            this.Property(p => p.Money).HasPrecision(18, 2);
            this.Property(p => p.CounterFee).HasPrecision(18, 2);
            this.Property(p => p.Remark).HasMaxLength(200);
            this.Property(p => p.SpecialName).HasMaxLength(20).IsRequired();
            this.Property(p => p.ApplicantName).HasMaxLength(20).IsRequired();
            this.Property(p => p.AuditName).HasMaxLength(20);
            this.Property(p => p.SerialNumber).HasMaxLength(100);



            this.HasRequired(p => p.Special).WithMany().HasForeignKey(f => f.SpecialId);
            this.HasRequired(p => p.SellerSupplier).WithMany().HasForeignKey(f => f.SupplyId);
            this.HasRequired(p => p.Applicant).WithMany().HasForeignKey(f => f.ApplicantId);
            this.HasMany(p => p.PaymentEntrust).WithRequired(p => p.Payment).HasForeignKey(f => f.PaymentId);
            this.HasOptional(p => p.Audit).WithMany().HasForeignKey(f => f.AuditId);
            this.HasMany(p => p.CollectInvoice).WithRequired(p => p.Payment).HasForeignKey(f => f.PaymentId);

        }
    }
}
